import request from "@/utils/request.js";
import { useTokenStore } from "@/store/token.js";

// 获取文章分类列表
export const articleCategoryListService = () => {
    // 获取tokenStore
    // const tokenStore = useTokenStore();
    // 通过配置的方式, 将token传入
    // return axios.get("/category", { headers: { 'Authorization': tokenStore.token } });
    return request.get("/category");
}

// 添加文章分类
export const addArticleCategoryService = (data) => {
    // 接收一个json格式数据, 并返回
    return request.post("/category", data);
}

// 修改文章分类
export const updateArticleCategoryService = (data) => {
    console.log('传递的数据是:', data);
    return request.put("/category", data);
}

// 删除文章分类
export const deleteArticleCategoryService = (id) => {
    return request.delete("/category?id=" + id);
}

// 获取文章列表
export const articleListService = (params) => {
    return request.get("/article", { params: params });
}

// 新增文章
export const addArticleService = (data) => {
    return request.post("/article", data);
}

// 修改文章
export const updateArticleService = (data) => {
    console.log(data);
    request.put("/article", data);
}

// 删除文章
export const deleteArticleService = (id) => {
    return request.delete("/article/" + id);
}